Skip to content

api-maintenance: libraries - #38

Merged
JaimeStill merged 4 commits into
mainfrom
libraries
Nov 11, 2026
Merged

JaimeStill merged 4 commits into
mainfrom
libraries

Conversation

@JaimeStill

Copy link
Copy Markdown
Contributor

api-maintenance · task 2/7 · libraries

Summary

go-database sweep.New(db, regs, shutdown, logger, sweep.Options{Unlocked, Gate, OnPass})
go-web-sdk middleware.RequestID(middleware.RequestIDOptions{Source, TrustedHeader})
web.WriteProblem(...) → web.Problem{Status, Title, Detail}.WriteFor(w, r)
go-observability docs name RequestIDOptions.Source; onto go-core v0.12.0
all three go-core v0.12.0 · go-database also sqlate v0.7.0, pgx v5.13.0

Core changes

  1. sweep.New — trailing options struct
    before: New(db, regs, shutdown, logger, opts ...Option) + Unlocked(), Gated(g), OnPass(h)
    after: New(db, regs, shutdown, logger, opts Options) Options{Unlocked bool; Gate Gate; OnPass Hook}
    why: functional options break construction-and-execution; zero Options keeps today's
    defaults (lock per pass, ErrNoTryLocker, no gate, warn log). The reactor now cancels
    at half the drain via reactor.Options{CancelAfter: reactor.CancelWithin(shutdown)}.
  2. middleware.RequestID — options struct, no panics
    before: RequestID(opts ...RequestIDOption) + WithIDSource(f), WithTrustedHeader(h)
    after: RequestID(opts RequestIDOptions) RequestIDOptions{Source func(*http.Request) string; TrustedHeader string}
    why: same rule; id order unchanged (Source → trusted header, 1–128 visible ASCII →
    generated hex). A nil Source / empty TrustedHeader is unset, where the options panicked.
  3. web.WriteProblem removed — five inputs
    before: web.WriteProblem(w, r, http.StatusTooManyRequests, "", detail)
    after: web.Problem{Status: http.StatusTooManyRequests, Detail: detail}.WriteFor(w, r)
    why: Problem.WriteFor is already the rule's struct-with-method form. Recoverer,
    ContentType, and rate-limit moved over; their response tests pass unchanged.
  4. Changelogs and standards
    go-database v0.12.0 and go-web-sdk v0.17.0: removals Breaking, "Migrating from" sections;
    go-observability v0.4.0: go-core requirement Breaking + doc fix; postgres v0.7.0,
    rate-limit v0.5.0, otlp v0.4.0: Breaking requirement lines. go-observability's
    STANDARDS.md gains the construction-and-execution pointer; the other two name the new forms.

Evidence

GOWORK=off mise run check go-database ✓ (base + postgres, 0 lint issues)
go-web-sdk ✓ (base + rate-limit, 0 lint issues)
go-observability ✓ (base + otlp, 0 lint issues)
GOWORK=off mise run currency exit 0 in all three (go-core v0.12.0 confirmed in each go.mod;
proxy.golang.org doesn't list it yet)
go test -run 'TestNew_|TestHandle_|TestSweeper_' ./sweep 9/9 pass (behaviors 1–4)
go test -run 'TestRequestID|TestRecoverer|TestContentType|TestProblem' ./ ./middleware ok
go test ./... in middleware/rate-limit ok (429 instance/detail asserted)
go doc -all ./sweep, ./middleware, . no Option/Unlocked/Gated/OnPass/RequestIDOption/
WithIDSource/WithTrustedHeader/WriteProblem
spec review: 12/12 behaviors met, no gaps
diff: go-database 10 files +173/−116 · go-web-sdk 17 files +178/−151 · go-observability 8 files +60/−22

Decided without you

  1. A nil sweep.Options.Gate or OnPass means the default, as passing nil to Gated/OnPass did.
  2. RequestID takes RequestIDOptions by value, read once at construction.
  3. Standards review cut TestRequestID_UnsetOptionsDoNotPanic (it couldn't fail beyond go test's
    own panic handling); its one new case joined the precedence table. Also reworded doc
    comments in all three repos.
  4. rate-limit v0.5.0 has two Breaking lines (go-core v0.12.0, go-web-sdk v0.17.0): it requires
    both directly, one line per requirement as in v0.4.0.
  5. Migration sections cover each repo's own removals and point to go-core's and sqlate's
    changelogs for theirs. Released changelog entries naming removed forms stay as history.
  6. go-observability's docs pass RequestIDSource as a value: it is the source function itself.
  7. Every new changelog entry is dated 2026-11-11; release re-dates any tag that lands later.
  8. Left as is: go-database README's sweep line says "paused under the service's quiesce gate",
    which holds only when a service sets Options.Gate; the wording predates this task.
  9. rate-limit's 500 (failed) path has no test, before or after; its call is a mechanical
    inline of the old WriteProblem.

Merge danger

one-way door for the six tags, which reach every consumer's module requirements:
go-database v0.12.0, postgres/v0.7.0; go-web-sdk v0.17.0, middleware/rate-limit/v0.5.0;
go-observability v0.4.0, otlp/v0.4.0
Accepting authorizes them. Each repo merges and tags its base, then moves its sub-module onto
the new base and tags it, lowest layer first. Two-way for the code and docs before tagging.
blast radius: go-web-service, both templates, go-storage, go-messaging, blobfs, and go-cli-sdk
stay on the old versions until their own tasks migrate; go-web-service's RequestID and
WriteProblem calls break only when it moves to go-web-sdk v0.17.0 (task service).

Needs you

(none)

…gx v5.13.0

- Base module requires go-core v0.12.0 (set explicitly: the tag is
  fetchable but not yet in the proxy's version list) and sqlate v0.7.0.
- postgres requires pgx v5.13.0; its indirect go-core and sqlate move to
  v0.12.0 and v0.7.0. Its go-database requirement stays at v0.11.0 for
  release prep.
- sweep: go-core v0.12.0 replaced reactor's option functions with a
  trailing reactor.Options, so New passes
  Options{CancelAfter: CancelWithin(shutdown)}. The sweeper still cancels
  a running pass at half the shutdown drain; sweep's exported API is
  unchanged.
- No sqlate TxOption/Isolation/ReadOnly use existed to adapt.
- go directive stays at 1.27.
sweep.New(db, regs, shutdown, logger, opts Options) replaces the
functional options. Options{Unlocked bool; Gate Gate; OnPass Hook};
the zero value keeps the defaults: claim each reclaimer's lock, refuse a
dialect without TryLocker as ErrNoTryLocker, hold no gate, and log
failed passes at warn. A nil Gate or OnPass means the default, as a nil
argument to Gated or OnPass did. The Option type and the Unlocked,
Gated, and OnPass functions are removed with no aliases.

The Sweeper keeps the Options value it was given, filling OnPass with
the warn-logging hook when nil. The reactor still cancels at
reactor.CancelWithin(shutdown). Only sweep's own tests called New in
this repository; they move to the new form. README, guides, and
CHANGELOG are left to the next slice.
- READMEs, context/README.md and package docs already show only the
  sweep.Options form (sweep/doc.go moved in the previous slice); the one
  remaining sweep.Unlocked() mention is in the released v0.10.0 entry,
  left as history.
- CHANGELOG.md v0.12.0 (2026-11-11), in go-core v0.12.0's and sqlate
  v0.7.0's format: a summary paragraph; Added sweep.Options; Changed
  sweep.New (Breaking) and the go-core v0.12.0 and sqlate v0.7.0
  requirements (Breaking, naming the breaks they pull into an importer's
  build); Removed sweep.Option, Unlocked, Gated, OnPass (Breaking); and
  "Migrating from v0.11.0" with old->new sweep.New calls, pointing to
  go-core's and sqlate's own migration sections for their calls.
- postgres/CHANGELOG.md v0.7.0: Breaking go-database v0.12.0
  requirement, and the pgx v5.13.0 bump with its Rows.Values panic fix
  (GHSA-w9rp-vfrh-q8vv) and the database/sql retry-safety fix.
  postgres/go.mod's go-database requirement stays at v0.11.0 for release
  prep.
- Compare links updated in both changelogs.
- STANDARDS.md construction-and-execution pointer names sweep.New's
  trailing sweep.Options, in the form go-core's and sqlate's pointers use.
Name sweep.New's unlocked case as opts setting Options.Unlocked
(context-architecture: the doc comment is the contract's home).
@JaimeStill
JaimeStill merged commit 8037bfa into main Nov 11, 2026
1 check passed
@JaimeStill
JaimeStill deleted the libraries branch November 11, 2026 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant